package com.cenxi.manage;

import com.cenxi.common.convert.RoleConvert;
import com.cenxi.common.dto.RoleDTO;
import com.cenxi.common.exceptions.ServiceException;
import com.cenxi.common.result.PageReq;
import com.cenxi.common.result.PageResp;
import com.cenxi.common.result.Req;
import com.cenxi.common.result.Resp;
import com.cenxi.common.vo.RoleVO;
import com.cenxi.dao.mapper.MenuMapper;
import com.cenxi.dao.mapper.RoleMapper;
import com.cenxi.utils.OssUploadUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Objects;

/**
 * @Author cenxi
 * @Date 2023/8/16 11:47
 * @Version 1.0
 */
@Slf4j
@Component
public class ManageMediaService {

    @Value("${oss.fileDomain}")
    private String fileDomain;

    @Autowired
    private OssUploadUtils ossUploadUtils;

    public String upload(MultipartFile file) {
        String msg = ossUploadUtils.uploadFile(file);
        if (Objects.isNull(msg) || "null".equals(msg)) {
            throw new ServiceException("上传文件失败");
        }
        return msg;
    }

    public String getDomainName() {
        return fileDomain;
    }
}
